// Copyright (c) 2019 Presto Labs Pte. Ltd.
// Author: xguo

#include "coin2/exchange/okex/symbology/currency.h"

#include <gtest/gtest.h>

TEST(OkexCurrency, constructor) {
  using namespace coin2::exchange::okex::symbology;
  using coin2::exchange::base::market::ExchangeType;
  using coin2::exchange::base::market::MarketType;

  int64_t resolve_ts = 1572502253 * 1e9;

  OkexCurrency usdt("USDT");
  EXPECT_EQ(usdt.currency(), "USDT");
  EXPECT_EQ(usdt.native_currency(MarketType::Spot), "USDT");
  EXPECT_EQ(usdt.rep_currency(), "USD");
  EXPECT_EQ(usdt.exchange(), ExchangeType::Okex);

  OkexCurrency usdk("USDK");
  EXPECT_EQ(usdk.currency(), "USDK");
  EXPECT_EQ(usdk.native_currency(MarketType::Spot), "USDK");
  EXPECT_EQ(usdk.rep_currency(), "USD");
  EXPECT_EQ(usdk.exchange(), ExchangeType::Okex);

  auto btc1 = OkexCurrency::FromNativeStr("BTC", resolve_ts);
  EXPECT_EQ(btc1.currency(), "BTC");
  EXPECT_EQ(btc1.native_currency(MarketType::Spot), "BTC");
  EXPECT_EQ(btc1.native_currency(MarketType::Futures), "BTC");
  EXPECT_EQ(btc1.exchange(), ExchangeType::Okex);

  auto btc2 = OkexCurrency::FromNativeStr("BTC", resolve_ts);
  auto btc3 = OkexCurrency::FromNormStr("BTC", resolve_ts);
  auto btc4 = OkexCurrency::FromStr("BTC", resolve_ts);
  EXPECT_EQ(btc2, btc1);
  EXPECT_EQ(btc3, btc1);
  EXPECT_EQ(btc4, btc1);

  auto bsv = OkexCurrency::FromStr("BSV", resolve_ts);
  EXPECT_EQ(bsv.currency(), "BCHSV");
  EXPECT_EQ(bsv.native_currency(MarketType::Spot), "BSV");

  auto bsv1 = OkexCurrency::FromStr("bsv", resolve_ts);
  EXPECT_EQ(bsv1.currency(), "BCHSV");
  EXPECT_EQ(bsv1.native_currency(MarketType::Spot), "BSV");

  auto bch = OkexCurrency::FromStr("BCH", resolve_ts);
  EXPECT_EQ(bch.currency(), "BCHABC");
  EXPECT_EQ(bch.native_currency(MarketType::Spot), "BCH");

  auto bch1 = OkexCurrency::FromStr("BCH", resolve_ts);
  EXPECT_EQ(bch1.currency(), "BCHABC");
  EXPECT_EQ(bch1.native_currency(MarketType::Spot), "BCH");
}
